package com.piece.module.generator.service;

import com.piece.core.framework.util.collection.MapUtil;
import com.piece.core.jpa.repository.BaseService;
import com.piece.module.generator.model.TbSysDbQuery;
import com.piece.module.generator.repository.TbSysDbQueryRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;

@Service
@Transactional
public class TbSysDbQueryService extends BaseService<TbSysDbQuery, String> {

    @Resource
    private TbSysDbQueryRepository tbSysDbQueryRepository;

    @PostConstruct
    public void initRepository() {
        setRepository(tbSysDbQueryRepository);
    }

    public int deleteByGroupName(String groupName) {
        return tbSysDbQueryRepository.deleteByProperties(MapUtil.builder(new HashMap<String, Object>()).put("groupName", groupName).build());
    }
}
